'use strict'
const path = require('path')

// const { defineConfig } = require('@/vue/cli-service')

function resolve(dir) {
  return path.join(__dirname, dir)
}

const name = '赛克档案系统'
const port = process.env.port || process.env.npm_config_port || 3000

module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? '/psych/' : '/',
  outputDir: 'dist',
  indexPath: 'index.html',
  assetsDir: 'static',
  lintOnSave: process.env.NODE_ENV === 'development',
  productionSourceMap: false,
  devServer: {
    port: port,
    open: true,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy: {
      [process.env.VUE_APP_BASE_API]: {
        target: 'https://xn--15t241ax9eqv8a.xn--fiqs8s',
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API]: ''
        }
      }
    }
  },
  configureWebpack: {
    name: name,
    resolve: {
      alias: {
        '@': resolve('src')
      }
    }
  },
  chainWebpack(config) {
    // 配置项目名称
    config.plugin('html').tap((args) => {
      args[0].title = name
      return args;
    })
  }
}